<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>执行工序编号</title>
    <meta name="viewport"
      content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../../../css/mui.min.css" rel="stylesheet" />
    <link href="../css/common.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../../../css/preview.css" />
    <style>
      /* .mui-content>.mui-table-view:first-child {
          margin-top: 1px;
      } */
      /* .icon{
        width: 35px;
        vertical-align: middle;
        margin-right: 10px;
      } */
      /* .mui-table-view-cell:after {
          left: 45px;
          height: 1px;
      } */
      /* .mui-table-view-cell{
        padding: 11px 11px 11px 11px;
      } */
      /* .mui-table-view:after {
          left: 45px;
      } */
      /* .mui-bar{
		  background-color: #0082E6;
	  } */
      .uls {
        padding: 20px 20px;
        list-style: none;
        margin: 0;
      }

      .mui-table-view:after {
        height: 0;
      }

      .titles {
        /* font-weight: bold; */
        margin-bottom: 24px;
        display: flex;
        justify-content: space-between;
      }

      .img_s {
        display: inline-block;
        width: 20px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #fff;
        background-color: #0082E6;
        border-radius: 100%;
        /* background: url(../img/word.png) no-repeat; */
        /* background-size: 100%; */
        margin: auto 0;
      }

      .bocks {
        padding: 0 5px;
      }

      .areas {
        background-color: ##F5F6F7;
        border: solid 1px #DCDCDC;
      }

      .upsign {
        overflow: hidden;
      }

      .imgss {
        float: left;
        margin-right: 10px;
      }

      .imgss img {
        width: 100%;
      }

      .signs {
        display: inline-block;
        width: 160px;
        height: 160px;
        /* border: solid 1px #3188FE; */
        border-radius: 5px;
        margin-right: 10px;
        margin-bottom: 10px;
        overflow: hidden;
        position: relative;
        /* background-color: #D4E6FF; */
      }

      .uploads {
        display: inline-block;
        width: 160px;
        height: 160px;
        /* border-radius: 5px; */
        background: url(../img/task/dianjipaizhao.png) no-repeat;
        background-size: 100%;
        margin-bottom: 20px;
      }

      .uploadsign {
        display: inline-block;
        width: 160px;
        height: 160px;
        margin-bottom: 20px;
        background-color: #D4E6FF;
        border: dotted 2px #3188FE;
        text-align: center;
        line-height: 10rem;
      }

      .submits {
        width: 100%;
        margin-top: 30px;
        height: 4 0px;
        border-radius: 30px;
      }

      /* .fixed-btn .mui-btn{
       width: 30%;
     } */
      .putList {
        display: flex;
        justify-content: space-between;
        padding-bottom: 20px;
      }

      .putList input {
        width: 80%;
      }

      .tits {
        margin-bottom: 20px;
      }

      .radios .rs1 {
        left: 100px;
      }

      .radios .rs2 {
        left: 180px;
      }

      .oks {
        position: absolute;
        left: 130px;
        top: 10px;
      }

      .nos {
        position: absolute;
        left: 210px;
        top: 10px;
      }

      .checkradios {
        margin-bottom: 20px;
      }

      .marks {
        display: inline-block;
        /* width: 70px; */
        height: 26px;
        line-height: 26px;
        /* background-color: #10B7AF; */
        border-radius: 2px;
        color: #fff;
        text-align: center;
        transform: skewX(-15deg);
        padding: 0 10px;
      }

      .lis {
        overflow: hidden;
      }

      .b_g1 {
        background-color: #FFD6D6;
      }

      .magTop {
        margin-top: 20px;
      }

      .tit {
        padding: 20px 0;
      }

      .sx_s {
        color: #fff;
      }

      .sx_s span {
        font-size: 17px;
      }

      .screens {
        position: absolute;
        top: 44px;
        left: 0;
        width: 100%;
        min-height: 200px;
        background-color: #fff;
        z-index: 999;
      }
      .mui-scroll-wrapper{
        overflow-y:scroll
      }
      .content_ul {
        padding: 10px 20px;
        height: 240px;
        position: relative;
      }
      .wrappers {
        position: relative;
        height: 160px;
      }
      .content_ul .rowli ul {
        padding: 0;
        margin: 0;
        list-style: none;
        border-bottom: solid 1px #DCDCDC;
        overflow: hidden;
        display: flex;
        flex-wrap: wrap;
        /* justify-content: space-between; */
      }

      .rowli ul li {
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        background-color: #F5F6F7;
        border: solid 1px #C2CFDA;
        border-radius: 3px;
        color: #000;
        /* float: left; */
        margin-right: 20px;
        margin-bottom: 20px;
        box-sizing: border-box;
        /* flex-grow: 1; */
      }

      .rowli ul li.ls {
        background-color: #3188FE;
        color: #fff;
      }

      .btnli {
        text-align: center;
        padding-top: 10px;
        display: flex;
        justify-content: space-between;
      }

      .btnli .btns {
        background-color: #E7ECF1;
      }

      .btnli button {
        width: 45%;
      }

      .signs .action-delete {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        text-align: center;
      }

      .action-delete .mui-icon {
        color: #FFFFFF;
      }

      .btn-active {
        border-style: dashed !important;
      }
      
      .tips {
        text-align: center;
        font-weight: bold;
        line-height: 40px;
        font-size: 18px;
        border-bottom: 1px solid #DCDCDC;
      }
      
      .tips-list {
        margin-top: 30%;
      }
    </style>
  </head>
  <body>
    <div id="container" v-cloak>
      <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left text-white"></a>
        <h1 class="mui-title">执行工序编号</h1>
        <a class="mui-pull-right mui-bar-right" @click="getSearch">
          <img src="../img/screen.png" width="18" style="margin-right: 3px;" />
          <span> 筛选</span>
        </a>
        <!-- <a class="mui-icon mui-icon-right-nav mui-pull-right mui-icon mui-icon-gear sx_s"
          @click="getSearch"><span>筛选</span></a> -->
      </header>
      <div class="mui-content page-wrap">
        <div class="mui-card-header" @tap="searchInfo()" style="padding: 20px;">
          <!-- <span class="img_s">1</span> -->
          <span>查询知识库</span>
        </div>
        <ul class="uls page-scroll" style="background: #fff;">
          <li class="lis" style="margin-bottom: 20px;">
             <div id="">
              {{idxs + 1}}、{{currentIndex + 1}}/{{allWp.length}} {{detail.position ? '辅助工序': '基本工序'}} 
            </div>
            <div>
              <span>工序编号：</span><span>{{detail.wpCode}}</span>
            </div>
            <div>
              <span>作业项目：</span><span>{{detail.jobProject}}</span>
            </div>
            <div>
              <span>作业方法：</span><span>{{detail.jobMethod}}</span>
            </div>
          </li>
          <li class="lis" v-for="(item,index) in projectList" :key="index" v-cloak>
            <!-- <img src="./img/xiaoxitongzhi_icon1.png" class="icon"> -->
            <div class="titles">
              <div>
                <span class="img_s">{{index+1}}</span>
                <span class="bocks">{{item.refInput.name}}
                  {{item.refInput.explain}}：{{inputShowText(item.refInput, dict)}}</span>
              </div>
              <span class="marks" :class="getTag(0, detail.tagId)">{{getTag(1, detail.tagId)}}</span>
            </div>
            <div v-if="!detail.isReturn">
              <div class="tits">{{item.refInput.name}}：</div>
              <div class="putList" v-if="item.refInput.typeValue == 'number'">
                <div>
                  <span>{{item.value}}</span>&nbsp;{{item.refInput.unitValue}}
                  <!-- <input type="text" v-model="item.value" :disabled="!isEdit" class="val1" /> -->
                </div>
              </div>
              <div v-if="item.refInput.typeValue == 'text'">
                <span>{{item.remarks}}</span>
                <!-- <textarea type="text" v-model="item.remarks" :disabled="!isEdit" class="areas"
                  placeholder="请输入"></textarea> -->
              </div>
              <div v-if="item.refInput.typeValue == 'boolean'">
                <span>{{item.value}}</span>
              </div>
              <div class="upsign" v-if="item.refInput.typeValue == 'img'">
                <div v-if="item.files" class="imgss">
                  <span class="signs" v-for="(v,i) in item.files">
                    <img :src="v.filePath? baseUrl + v.filePath:''"
                      :data-preview-src="v.filePath?baseUrl + v.filePath:''" :data-preview-group="index" />
                    <div class="action-delete" @tap="deleteImg(index, i, 1)" v-show="isEdit">
                      <span class="mui-icon mui-icon-trash"></span>
                    </div>
                  </span>
                </div>
                <span class="uploads" @tap="addPics(index)" v-show="isEdit"></span>
              </div>
            </div>
          </li>
          <li v-if="!detail.isReturn">
            <div class="checkradios radios1">
              <div class="mui-input-row mui-radio radios">
                <label>是否正常：</label>
                <input name="radio1" :checked="detail.isAnomaly?true:false" :disabled="!isEdit" type="radio" value="1"
                  class="rs1">
                <span class="oks">否</span>
                <input name="radio1" :checked="detail.isAnomaly?false:true" :disabled="!isEdit" type="radio" value="2"
                  class="rs2">
                <span class="nos">是</span>
              </div>
            </div>
          </li>
          <li class="lis footers" v-if="detail.isAnomaly">
            <div>
              <textarea name="" class="areas" v-if="anomalyInfo" v-model="anomalyInfo.remarks" cols="30" rows="3"
                :disabled="!isEdit" placeholder="请输入"></textarea>
            </div>
            <div class="upsign">
              <div v-if="anomalyInfo" class="imgss">
                <span class="signs" v-for="(v,index) in anomalyInfo.files">
                  <img :src="v.filePath?baseUrl + v.filePath:''" :data-preview-src="v.filePath?baseUrl + v.filePath:''"
                    :data-preview-group="1" />
                  <div class="action-delete" @tap="deleteImg(v, index,2)" v-show="isEdit">
                    <span class="mui-icon mui-icon-trash"></span>
                  </div>
                </span>
              </div>
              <span class="uploads" @tap="addPic(1)" v-show="isEdit"></span>
            </div>
          </li>
          <li v-if="!detail.isReturn">
            <div class="checkradios radios2">
              <div class="mui-input-row mui-radio radios">
                <label>是否缺陷：</label>
                <input name="radio2" :checked="detail.isFault?true:false" :disabled="!isEdit" type="radio" value="1"
                  class="rs1">
                <span class="oks">是</span>
                <input name="radio2" :checked="detail.isFault?false:true" :disabled="!isEdit" type="radio" value="2"
                  class="rs2">
                <span class="nos">否</span>
              </div>
            </div>
          </li>
          <li class="lis footers" v-if="detail.isFault">
            <div>
              <textarea name="" class="areas" v-if="faultInfo" v-model="faultInfo.remarks" cols="30" rows="3"
                :disabled="!isEdit" placeholder="请输入"></textarea>
            </div>
            <div class="upsign">
              <div v-if="faultInfo" class="imgss">
                <span class="signs" v-for="(v,index) in faultInfo.files">
                  <img :src="v.filePath?baseUrl + v.filePath:''" :data-preview-src="v.filePath?baseUrl + v.filePath:''"
                    :data-preview-group="1" />
                  <div class="action-delete" @tap="deleteImg(v, index,3)" v-show="isEdit">
                    <span class="mui-icon mui-icon-trash"></span>
                  </div>
                </span>
              </div>
              <span class="uploads" @tap="addPic(2)" v-show="isEdit"></span>
            </div>
          </li>
          <li class="lis">
            <div class="btn_s" v-if="detail.materials">
              <!-- <button type="button" v-if="!fileimg" @tap="defectsfn(detail.anomalyInfo)" class="mui-btn mui-btn-danger">生成缺陷</button> -->
              <!-- <button type="button" @tap="equipmentList(detail.materials)" class="mui-btn mui-btn-primary">更换设备</button> -->
              <ul class="mui-table-view lists" v-for="(item,index) in detail.materials" :key="item.id">
                <li class="lis">
                  <span class="left_name">物料号：</span>
                  <span class="right_name">{{item.materialArchivesId}}</span>
                </li>
                <li class="lis">
                  <span class="left_name">物料描述：</span>
                  <span class="right_name">{{item.description}}</span>
                </li>
                <li class="lis">
                  <span class="left_name">使用数量：</span>
                  <span class="right_name">{{item.quantity}} {{item.measdoc}}</span>
                </li>
              </ul>
            </div>
          </li>
          <li v-if="detail.tagId && !detail.isReturn">
            <div class="tit"><span>负责人拍照：</span></div>
            <div class="upsign">
              <div v-if="signInfo && signInfo.takeImg && signInfo.takeImg.filePath" class="imgss">
                <span class="signs">
                  <img class="takeImgs" :src="baseUrl + signInfo.takeImg.filePath"
                    :data-preview-src="baseUrl + signInfo.takeImg.filePath" :data-preview-group="1" />
                  <div class="action-delete" @tap="deleteImgs(3)" v-show="isEdit">
                    <span class="mui-icon mui-icon-trash"></span>
                  </div>
                </span>
              </div>
              <span class="uploads" @tap="addPic(3)" v-show="isEdit"></span>
            </div>
          </li>
          <li v-if="detail.tagId && !detail.isReturn">
            <div class="tit"><span>签字(必填)</span></div>
            <div class="signs" id="sign" @tap="toSign" v-if="signInfo">
              <img id="signImg" style="width: 100%;height: 100%;"
                :src="signInfo.signImg && signInfo.signImg.filePath? baseUrl + signInfo.signImg.filePath:''"
                v-show="signInfo.signImg &&  signInfo.signImg.filePath" />
            </div>
            <div v-show="isEdit">点击图片修改签字</div>
            <!-- <span class="uploadsign mui-icon mui-icon-plusempty" @tap="toSign">点击签字</span> -->
          </li>
        </ul>
        <div class="fixed-btn" style="justify-content:center;color: red;" v-if="detail.isReturn">
          此工序已退回
        </div>
        <div class="fixed-btn" v-else>
          <!-- <button type="button" @tap="askback" class="mui-btn mui-btn-danger mui-btn-outlined">申请退回</button>
        <button type="button" @tap="saveInfo()" class="mui-btn mui-btn-primary">保存</button> -->
          <button type="button" @tap="nextInfo()" class="mui-btn mui-btn-primary">下一个</button>
        </div>
        <div class="screens mui-popover mui-popover-top">
          <div class="head_s mui-segmented-control mui-segmented-control-inverted mui-segmented-control-primary "
            style="background-color: #fff;">
            <a class="mui-control-item mui-active" href="#items1"><span class="txt">全部</span></a>
            <a class="mui-control-item" href="#items2"><span class="txt">已完成</span></a>
            <a class="mui-control-item" href="#items3"><span class="txt">未完成</span></a>
          </div>
          <div class="content_ul">
            <div class="wrappers">
              <div class="mui-scroll-wrapper">
                <div class="mui-scroll">
                  <div class="rowli mui-slider-item mui-control-content mui-active" id="items1">
                    <ul v-if="aList.length>0">
                      <li v-for="(v,index) in aList" :key="v.id" :class="[idxs == v.index? 'btn-active': '']"
                        @tap="nextInfo(v.id,v.index)">{{v.index+1}}</li>
                    </ul>
                  </div>
                  <div class="rowli mui-slider-item mui-control-content" id="items2">
                    <ul v-if="yList.length>0">
                      <li v-for="(v1,index) in yList" :key="v1.id" :class="[idxs == v1.index? 'btn-active': '']"
                        @tap="nextInfo(v1.id,v1.index)">{{v1.index+1}}</li>
                    </ul>
                  </div>
                  <div class="rowli mui-slider-item mui-control-content" id="items3">
                    <ul v-if="wList.length>0">
                      <li v-for="(v2,index) in wList" :key="v2.id" :class="[idxs == v2.index? 'btn-active': '']"
                        @tap="nextInfo(v2.id,v2.index)">{{v2.index+1}}</li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
            <div class="btnli">
              <button type="button" class="mui-btn btns" @tap="getSearch()">关闭</button>
              <button type="button" class="mui-btn mui-btn-primary" @tap="endSearch()">确认</button>
            </div>
          </div>
        </div>
      </div>
      
      <div class="mui-backdrop" v-show="isMask">
        <div class="tips-list">
          <div class="mui-card">
            <div class="tips">查询知识库</div>
            <div class="mui-card-content">
              <ul class="mui-table-view" v-if="dataList.length>0">
                <li class="mui-table-view-cell" v-for="(item,index) in dataList" :key="item.id" @tap="toDetails(item.id)">
                  <a class="mui-navigate-right">
                    <span>{{item.deviceModelName}}</span> -
                    <span>{{item.machineModel}}</span><br />
                    <span>{{item.title}}</span>
                  </a>
                </li>
              </ul>
              <div v-else>暂无数据</div>
            </div>
            <div class="mui-card-footer">
              <div></div>
              <button type="button" class="mui-btn" @click="isMask=false">关闭</button>
              <!--<button type="button" class="mui-btn mui-btn-primary">确定</button>-->
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="../../../js/mui.js"></script>
    <script src="../../../js/mui.pullToRefresh.js"></script>
    <script src="../../../js/mui.pullToRefresh.material.js"></script>
    <script src="../../../js/jquery-1.7.2.min.js"></script>
    <script src="../../../js/vue.js"></script>
    <script src="../js/main.js"></script>
    <script src="../js/mkeyplus.base.js"></script>
    <script src="../js/uploadImage.js"></script>
    <script src="../js/sqlite.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../../js/mui.zoom.js"></script>
    <script src="../../../js/mui.previewimage.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
      mui.init()
      mui.previewImage()
      var ids = 1;
      var tagId = 271;
      var idxs = 0;
      var dict = {}
      var self = null
      // var dict=dict
      // materialsthis anomalyInfo
      let faultInfo = null
      let materialsthis = null

      // console.log('aaaa',JSON.parse(materialsthis))
      if (window.plus) {
        plusready();
      } else {
        document.addEventListener('plusready', plusready, false);
      }

      function plusready() {
        var self = plus.webview.currentWebview();
        console.log('idssss', self.projectTaskId)
        // vm.form.projectTaskId = self.projectTaskId
        // vm.form.projectCategory = self.projectCategory
        ids = self.projectTaskId
        tagId = self.tagId
        idxs = self.idxs
        vm.idxs = self.idxs
        vm.aList = self.aList
        // vm.getDetail()
        mui.baseApp.getDict(['valueUnit', 'valueType', 'inputSymbol', 'wpTag']).then(res => {
          console.log("-------------")
          console.log(res)
          vm.dict = res
          dict = res
          vm.wpTagList = res.wpTag
        })
        getProject(ids)
        vm.getLists()
        // this.getWpTag()
        // if(materialsthis){
        //   vm.detail.materials=materialsthis
        // }
      }

      var vm = new Vue({
        el: '#container',
        dicts: ['valueUnit', 'valueType', 'inputSymbol'],
        data: {
          fileimg: false,
          idxs: 0,
          isEdit: false,
          detail: {},
          projectList: [],
          anomalyInfo: {
            remarks: '',
            files: [],
          },
          faultInfo: {
            remarks: '',
            files: [],
          },
          materialsthis: [],
          dict: dict,
          wpTagList: [],
          signInfo: {
            takeImg: {},
            signImg: {}
          },
          aList: [],
          yList: [],
          wList: [],
          allList: [],
          images: [],
          baseUrl: mui.baseApp.serverUrl,
          allWp: [], //当前基本工序加辅助工序
          currentIndex: 0, //当前基本工序加辅助工序所在索引
          isMask: false,
          dataList: [],
        },
        computed: {
          headers() {
            return function(item, i) {
              return item.value ? item.value.split(',')[i] : ''
            }
          }
        },
        created: function() {
          // this.getWpTag()
          // getProject()
          // this.getLists()
        },
        methods: {
          saveInfo() {
            console.log('编辑数据', this.projectList)
            let arrys = this.projectList.map(res => {
              // let val=''
              // if(res.val1||res.val1){
              // if(showValue2(res.refInput,dict)){
              //   let val=res.val1+','+res.val2
              //   delete res.val1
              //   delete res.val2
              //   res.value=val
              // }
              // }

              return res
            })
            console.log('xin行', arrys, this.detail)
            // return false
            let parm = {
              projectTaskWpId: ids,
              stage: 3,
              inputs: arrys,
              anomalyInfo: this.anomalyInfo,
              materials: this.materialsthis,
              faultInfo: this.faultInfo,
              isAnomaly: this.fileimg == true ? true : false,
              "isFault": this.detail.isFault,
              "isReturn": this.detail.isReturn,
              "isRectify": this.detail.isRectify,
              "isPass": this.detail.isPass
            }
            mui.baseApp.httpRequst("post", "/app/api/project/execution/wp/execution", parm, function(data) {
              console.log('数据列表', data)
              // plus.nativeUI.closeWaiting();
              mui.toast(data.msg)
              // mui.baseApp.openWindow('./riskList.html')

            }, function() {
              // plus.nativeUI.closeWaiting()
              mui.toast("保存失败")
              console.log("获取数据失败");
            })
          },
          askback() {
            mui.confirm('因您不能执行此工序，需要退回', '提示', ['取消', '确定'], function(v) {
              // alert('12')
              console.log(v)
              if (v.index === 1) {
                mui.baseApp.httpRequst("get", "/app/api/project/execution/return/" + ids, function(data) {
                  console.log('回退', data)
                  // plus.nativeUI.closeWaiting();
                  mui.toast(data.msg)

                }, function() {
                  // plus.nativeUI.closeWaiting()
                  console.log("获取数据失败");
                })
              }
            })

          },
          getTag(v, tagId) {
            if (!tagId) {
              return ''
            }
            let tags = this.wpTagList.find(res => {
              // console.log('in',res)
              if (res.id == tagId) {
                return res
              }
            })
            // console.log('23',tags.label)
            if(tags){
              if (tags.label == "停工待检点") {
                return v == 0 ? 'b_g1' : '停工待检点'
              } else if (tags.label == "现场见证点") {
                return v == 0 ? 'b_g2' : "现场见证点"
              } else if (tags.label == "旁站点") {
                return v == 0 ? 'b_g3' : "旁站点"
              } else if (tags.label == "技术监督") {
                return v == 0 ? 'b_g4' : "技术监督"
              }
            }
            // return tags
          },
          getWpTag() {
            mui.baseApp.httpRequst("post", "/app/sys/dictItem/getDictDetail", {
              dictName: 'wpTag'
            }, function(data) {
              console.log('数据列表wpTag', data)
              this.wpTagList = data.data
            }, function() {
              // plus.nativeUI.closeWaiting()
              console.log("获取数据失败");
            })
          },
          // 添加图片
          addPics(index) {
            var that = this;
            page.imgUp(function(path) {
              console.log('compress image path: ' + path)

              plus.nativeUI.showWaiting('上传中')
              mui.baseApp.upLoadFile(path, function(res) {
                console.log(res)
                plus.nativeUI.closeWaiting()
                mui.toast("上传成功")
                if (that.projectList[index].files) {
                  that.projectList[index].files.push({
                    fileId: res.data.id,
                    filePath: res.data.fileDirectory
                  })
                } else {
                  that.projectList[index].files = [{
                    fileId: res.data.id,
                    filePath: res.data.fileDirectory
                  }]
                }

              })
            });
          },
          // 添加图片
          addPic(index) {
            var that = this;
            page.imgUp(function(path) {
              console.log('compress image path: ' + path)
              plus.nativeUI.showWaiting('上传中')
              mui.baseApp.upLoadFile(path, function(res) {
                console.log(res)
                plus.nativeUI.closeWaiting()
                mui.toast("上传成功")
                if (index == 3) {
                  that.signInfo.takeImg = {
                    fileId: res.data.id,
                    filePath: res.data.fileDirectory
                  }

                } else if (index == 2) {
                  that.faultInfo.files.push({
                    img: path,
                    fileId: res.data.id,
                    filePath: res.data.fileDirectory
                  })
                } else if (index == 1) {
                  that.anomalyInfo.files.push({
                    img: path,
                    fileId: res.data.id,
                    filePath: res.data.fileDirectory
                  })
                }
              })

              // var images = that.checkDetails[index].images;
              // images.push(path);
              // that.$set(that.checkDetails[index], 'images', images);
            });
          },
          // 删除图片
          deleteImg(item, index, i) {
            var that = this;
            mui.confirm('确定要删除此图片吗？', '提示', ['取消', '确认'], function(e) {
              console.log(e.index)
              if (e.index === 1) { // 确认
                if (i == 3) {
                  that.faultInfo.files.splice(index, 1)
                  // var images = that.checkDetails[index].images;
                  // images.splice(i, 1);
                  //                	that.$set(that.anomalyInfo.files, 'filePath', Path);
                } else
                if (i == 2) {
                  that.anomalyInfo.files.splice(index, 1)
                  // var images = that.checkDetails[index].images;
                  // images.splice(i, 1);
                  //                	that.$set(that.anomalyInfo.files, 'filePath', Path);
                } else if (i == 1) {
                  var images = that.projectList[item].files
                  images.splice(index, 1);
                  //                  that.$set(that.projectList[index], 'images', images);
                }

              } else {
                console.log('取消删除')
              }
            }, 'div');
          },
          // 删除图片
          deleteImgs(i) {
            var that = this;
            mui.confirm('确定要删除此图片吗？', '提示', ['取消', '确认'], function(e) {
              console.log(e.index)
              if (e.index === 1) { // 确认
                var images = that.signInfo.takeImg.filePath = ''
                // var images = that.checkDetails[index].images;
                // images.splice(i, 1);
                that.$set(that.signInfo.takeImg, 'filePath', images);
              } else {
                console.log('取消删除')
              }
            }, 'div');
          },
          nextInfo(vid, index) {
            if (vid) {
              idxs = index
              this.idxs = index
              ids = vid
              // this.saveInfo()
              getProject(vid)
              mui('.screens').popover('toggle');
            } else {
              if(vm.currentIndex + 1 < vm.allWp.length) {
                vm.currentIndex++
                handleData({
                  data: vm.allWp[vm.currentIndex]
                })
                return
              }
              if (this.aList.length > 1 && this.aList.length > idxs + 1) {
                idxs++
                this.idxs = idxs
                ids = this.aList[idxs]['id']
                // this.saveInfo()
                getProject(ids)
              } else {
                mui.toast('没有了')
              }
            }

          },
          getLists() {
            vm.wList = []
            vm.yList = []
            this.aList.forEach((res, index) => {
              res.index = index
              // console.log('idds',res)
              if (res.status == 4) {
                // console.log('idds12',res)
                vm.yList.push(res);
              } else if (res.status == 0 || res.status == 1) {
                vm.wList.push(res);
              }
            })
            // console.log('idds11',this.aList)
          },
          getSearch() {
            mui('.screens').popover('toggle');
            // this.searchs=!this.searchs
          },
          endSearch() {
            let h = $(".head_s .mui-active").attr('href')
            if (h == '#items1') {
              this.allList = this.aList;
            } else if (h == '#items2') {
              this.allList = this.yList;
            } else if (h == '#items3') {
              this.allList = this.wList;
            }
            mui('.screens').popover('toggle');
          },
          toSign() {
            return
            mui.baseApp.openWindow('../common/sign.html', {
              projectId: ids,
              anomalyInfo: anomalyInfo
            })
        },
            defectsfn(anomalyInfo) {
            mui.baseApp.openWindow('./defect.html', {
              projectId: ids,
              anomalyInfo: anomalyInfo
            })
          },
          equipmentList(materials) {
            mui.baseApp.openWindow('./materialList.html', {
              projectId: ids,
              materials: materials
            })
          },
          showValue2(obj, dict) {
            if (!obj.typeSubId) {
              return false
            }
            let types = dict.id.inputSymbol[obj.typeSubId].value // 符号
            let typeSub = ['()', '[]', '(]', '[)', ')(', '][', ')[', '](']
            return typeSub.includes(types)
          },
          inputShowText(obj, dict) {
            // console.log(obj)
            let type = dict.id.valueType[obj.typeId].value // 类型
            if (type == 'text') {
              return obj.value
            } else if (type == 'img') {
              return '无'
            } else if (type == 'boolean') {
              return '是否'
            } else {
              let unit = dict.id.valueUnit[obj.unitId].value // 单位
              let symbol = dict.id.inputSymbol[obj.typeSubId].value // 符号
              let valueArr = obj.value.split(",")
              let showText = ''
              switch (symbol) {
                case '>':
                  showText = '>' + valueArr[0] + unit
                  break;
                case '≥':
                  showText = '≥' + valueArr[0] + unit
                  break;
                case '<':
                  showText = '<' + valueArr[0] + unit
                  break;
                case '≤':
                  showText = '≤' + valueArr[0] + unit
                  break;
                case '=':
                  showText = '=' + valueArr[0] + unit
                  break;
                case '!=':
                  showText = '!=' + valueArr[0] + unit
                  break;
                case '()':
                  showText = '>' + valueArr[0] + unit + '  ' + '<' + valueArr[1] + unit
                  break;
                case '[]':
                  showText = '≥' + valueArr[0] + unit + '  ' + '≤' + valueArr[1] + unit
                  break;
                case '(]':
                  showText = '>' + valueArr[0] + unit + '  ' + '≤' + valueArr[1] + unit
                  break;
                case '[)':
                  showText = '≥' + valueArr[0] + unit + '  ' + '<' + valueArr[1] + unit
                  break;
                case ')(':
                  showText = '<' + valueArr[0] + unit + '  ' + '>' + valueArr[1] + unit
                  break;
                case '][':
                  showText = '≤' + valueArr[0] + unit + '  ' + '≥' + valueArr[1] + unit
                  break;
                case ')[':
                  showText = '<' + valueArr[0] + unit + '  ' + '≥' + valueArr[1] + unit
                  break;
                case '](':
                  showText = '≤' + valueArr[0] + unit + '  ' + '>' + valueArr[1] + unit
                  break;
                default:
                  showText = obj.value + unit
                  break
              }
              return showText
            }
          },
          searchInfo() {
            this.isMask = true
            // /app/api/project/execution/wpKnowledge/{projectTaskWpId}

          },
          getInfo() {
            let that = this;
            mui.baseApp.httpRequst("get", "/app/api/project/execution/wpKnowledge/" + ids, {}, function(data) {
              console.log('知识库', data)
              if (data.code == '0') {
                that.dataList =  data.data
              } else {
                mui.toast(data.msg)
              }
            })
          },
          toDetails(id){
            mui.baseApp.openWindow("../knowledge/device/detail.html",{
              ids: id,
             })
          },
        },
      });
      (function($) {
        //阻尼系数
        var deceleration = mui.os.ios ? 0.003 : 0.0009;
        $('.mui-scroll-wrapper').scroll({
          bounce: false,
          indicators: true, //是否显示滚动条
          deceleration: deceleration
        });
      })(mui);
      function getProject(ids) {
        plus.nativeUI.showWaiting('加载中...');
        mui.baseApp.httpRequst("get", "/app/api/project/execution/wp/detail/" + ids, null, function(data) {
          console.log('数据列表102', data)
          plus.nativeUI.closeWaiting();
          if(data.data.status != 3) { // status3 代表当前登录人退回   isReturn 代表当前工序有退回记录  退回换执行人  isReturn不变  手动变为false
            data.data.isReturn = false
          }
          let subWps = data.data.subWps
          let prefix = []; // 前置
          let suffix = []; // 后置
          subWps.forEach(item => {
            item.isReturn = data.data.isReturn 
            if(item.position == 1) {
              prefix.push(item)
            } else {
              suffix.push(item)
            }
          })
          delete data.data.subWps
          vm.allWp = prefix.concat([data.data]).concat(suffix)
          vm.currentIndex = 0
          handleData({
            data: vm.allWp[vm.currentIndex]
          })
        }, function() {
          plus.nativeUI.closeWaiting()
          console.log("获取数据失败");
        })
        
        vm.getInfo()
      }
      
      function handleData(data) {
        vm.detail = data.data
        let lists = data.data.inputs
        console.log('新数据列表12工序', lists)
        vm.projectList = lists
        vm.anomalyInfo = data.data.anomalyInfo ? data.data.anomalyInfo : {
            remarks: '',
            files: []
          },
          vm.materialsthis = data.data.materials ? data.data.materials : []
        vm.faultInfo = data.data.faultInfo ? data.data.faultInfo : {
          remarks: '',
          files: []
        }
        vm.signInfo = data.data.signInfo ? data.data.signInfo : {
          takeImg: {},
          signImg: {}
        }
      }
      
      mui(".radios1").on('change', 'input[type=radio]', function() {
        var v = $(this).val();
        $(this).attr('checked', true)
        if (v == 1) {
          vm.detail.isAnomaly = true
          // vm.fileimg = true
        } else {
          vm.detail.isAnomaly = false
          // vm.fileimg = false
        }
      });
      mui(".radios2").on('change', 'input[type=radio]', function() {
        var v = $(this).val();
        $(this).attr('checked', true)
        if (v == 1) {
          vm.detail.isFault = true
          // vm.fileimgs = true
        } else {
          vm.detail.isFault = false
          // vm.fileimgs = false
        }
      });

      $(document).ready(function() {
        let height = document.documentElement.clientHeight
        //防止软键盘弹出底部按钮顶上来
        $(".mui-content").css('height', height + 'px')
      })
     	$("#sign").click(function() {
        // mui.baseApp.openWindow('../common/sign.html')
      })
      window.addEventListener('faultInfo', function(event) {
        let data = event.detail
        console.log('aaa1233366', data)
        vm.detail.isFault = true
        // vm.detail.isAnomaly = true
        // vm.fileimg=true;
        faultInfo = data.faultInfo
        vm.faultInfo = data.faultInfo
      });
      window.addEventListener('materialsthis', function(event) {
        let data = event.detail
        console.log('aaa123', data)
        materialsthis = data.materialsthis
        vm.materialsthis = data.materialsthis
      });
    </script>
  </body>
</html>
